import { Column, Entity, JoinTable, ManyToMany } from 'typeorm';
import { BaseEntity } from '../../../common/baseEntity/index';
import { Permission } from '../../permission/entities/permission.entity';

@Entity('role')
export class Role extends BaseEntity {
  @Column({ type: 'varchar', length: 50, comment: '角色名称' })
  name: string;

  @Column({ type: 'varchar', length: 255, unique: true, comment: '角色编码' })
  code: string;

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '角色描述' })
  description: string;

  @ManyToMany(() => Permission)
  @JoinTable({ name: 'role_paermission_relation' })
  permissions: Permission[];
}
